package rcs34.android.photopublishare;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Map.Entry;
import java.util.Set;

import Utils.ImageUtils;
import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.provider.MediaStore;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

public class AdapterExif extends BaseAdapter implements ListAdapter {
	private final String LOGTAG = getClass().getName();
	private ActivityPreview activity;
	private ArrayList<String[]> items=new ArrayList<String[]>();

	public AdapterExif(ActivityPreview _activity) {
		super();
		activity = _activity;
	}

	private class ViewHolder {
		public TextView tag;
		public TextView value;
	}

	public View getView(int _position, View _convertView, ViewGroup _parent) {
		View result = _convertView;
		if (result == null) {
			LayoutInflater inflater = activity.getLayoutInflater();
			result = inflater.inflate(R.layout.item_exif, null);
			ViewHolder viewHolder = new ViewHolder();
			viewHolder.tag = (TextView) result.findViewById(R.id.itemExifKey);
			viewHolder.value = (TextView) result
					.findViewById(R.id.itemExifValue);
			result.setTag(viewHolder);
		}
		ViewHolder holder = (ViewHolder) result.getTag();
		holder.tag.setText(((String[])getItem(_position))[0] + ": ");
		holder.value.setText(((String[])getItem(_position))[1]);
		return result;
	}

	public int getCount() {
		return items.size();
	}

	public Object getItem(int _position) {
		return items.get(_position);
	}

	public long getItemId(int _position) {
		return _position;
	}

	public int getItemViewType(int _position) {
		return 0;
	}

	public int getViewTypeCount() {
		return 1;
	}

	public boolean hasStableIds() {
		return true;
	}

	public boolean isEmpty() {

		return items.isEmpty();
	}

	public boolean areAllItemsEnabled() {
		return true;
	}

	public boolean isEnabled(int position) {
		return true;
	}
	
	public void setItems(ArrayList<String[]> _items){
		items=_items;
		notifyDataSetChanged();
	}

	
}
